<script>

function updateGraph()
{
	var from = document.getElementById('from').value;
	var to = document.getElementById('to').value;
	var groupby = document.getElementById('group_by').value;
	
	var displayStock = 0;
	if (document.getElementById('display_stock').checked)
		displayStock = 1;
	var displayOutgoing = 0;
	//if (document.getElementById('display_outgoing').checked)
	//	displayOutgoing = 1;
	var displayIngoing = 0;
	//if (document.getElementById('display_ingoing').checked)
	//	displayIngoing = 1;
	
	var url = '<?php echo $this->getUrl('AdvancedStock/Products/StockGraph', array('product_id' => $this->getProduct()->getId())); ?>';
	url = url + 'from/' + from + '/to/' + to + '/groupby/' + groupby + '/displaystock/' + displayStock + '/displayoutgoing/' + displayOutgoing + '/displayingoing/' + displayIngoing;
	
	document.getElementById('img_product_graph').src = url; 
	document.getElementById('img_product_graph').style.display = '';

}

</script>

<div class="entry-edit-head">
	<h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Stock graph'); ?></h4> 
</div>
<div class="entry-edit">
        <fieldset>
        
<table border="0">
	<tr>
		<th width="200" align="right"><?php echo $this->__('From :'); ?>
			<input size="8" type="text" id="from" name="from" value="<?php echo date('Y-m-d', time() - 3600*24*365); ?>">
			<img src="<?php echo $this->getSkinUrl('images/grid-cal.gif') ?>" class="v-middle" id="img_calendar_from" />
			<script type="text/javascript">
				Calendar.setup({
					inputField : 'from',
					ifFormat : '%Y-%m-%e',
					button : 'img_calendar_from',
					align : 'Bl',
					singleClick : true
				});
			</script>
		</td>
		<th width="200" align="right"><?php echo $this->__('To :'); ?>
			<input size="8" type="text" id="to" name="to" value="<?php echo date('Y-m-d', time()); ?>">
			<img src="<?php echo $this->getSkinUrl('images/grid-cal.gif') ?>" class="v-middle" id="img_calendar_to" />
			<script type="text/javascript">
				Calendar.setup({
					inputField : 'to',
					ifFormat : '%Y-%m-%e',
					button : 'img_calendar_to',
					align : 'Bl',
					singleClick : true
				});
			</script>
		</td>
		<th width="200" align="right"><?php echo $this->__('Group by :'); ?><?php echo $this->getGroupByAsCombo('group_by'); ?></td>
		<td width="200"><input onclick="updateGraph();" type="button" value="<?php echo $this->__('Update Graph'); ?>"></td>
	</tr>
</table>
<table border="0">
	<tr>
		<td width="50" style="background-color: blue;">&nbsp;</td>
		<td width="100"><?php echo $this->__('Stock level'); ?></td>
		<td width="100"><input type="checkbox" value="1" id="display_stock" checked></td>
	</tr>
</table>

<p>&nbsp;</p>
<p><img src="" id="img_product_graph" name="img_product_graph" style="display: none;"></p>

	</fieldset>
</div>